#include "stdafx.h"
#include "ckLandsatRawMetaGroup.h"
#include <string>

namespace ck
{
	namespace data
	{
		LandsatRawMetaGroup::LandsatRawMetaGroup()
		{
			m_iter = m_pairs.begin();
		}

		LandsatRawMetaGroup::~LandsatRawMetaGroup()
		{
		}


		RESULTCODE LandsatRawMetaGroup::Set(const char* szKey, const char* szValue)
		{
			if (szKey == NULL || szValue == NULL)
			{
				return RC_FAILURE;
			}

			std::string strKey = szKey;
			std::string strValue = szValue;
			m_pairs[strKey] = strValue;

			return RC_SUCCESS;
		}

		void LandsatRawMetaGroup::Reset()
		{
			m_iter = m_pairs.begin();
		}

		void LandsatRawMetaGroup::Next()
		{
			if (m_iter != m_pairs.end())
			{
				m_iter++;
			}
		}

		bool LandsatRawMetaGroup::IsEOF()
		{
			return (m_iter == m_pairs.end());
		}

		const char* LandsatRawMetaGroup::GetKey()
		{
			if (m_iter == m_pairs.end())
			{
				return NULL;
			}

			return m_iter->first.c_str();
		}

		const char* LandsatRawMetaGroup::GetValue()
		{
			if (m_iter == m_pairs.end())
			{
				return NULL;
			}

			return m_iter->second.c_str();
		}

		const char*	LandsatRawMetaGroup::GetValue(const char* szKey)
		{
			if (szKey == NULL)
			{
				return NULL;
			}
			std::map<std::string, std::string>::iterator iter;
			iter = m_pairs.find(szKey);
			if (iter == m_pairs.end())
			{
				return NULL;
			}
			return iter->second.c_str();
		}

		bool LandsatRawMetaGroup::Find(const char* szKey)
		{
			if (!szKey)
			{
				return false;
			}

			std::map<std::string, std::string>::iterator iter;
			iter = m_pairs.find(szKey);
			return (iter != m_pairs.end());
		}

		RESULTCODE LandsatRawMetaGroup::SetName(const char* szName)
		{
			if (szName == NULL)
			{
				return RC_FAILURE;
			}

			m_name = szName;

			return RC_SUCCESS;
		}
		const char*	LandsatRawMetaGroup::GetName()
		{
			return m_name.c_str();
		}

	}
}